<?php
    $table = $this->inflect($this->table)->toTitle();
    $singular = $this->inflect($table)->singularize();
    $pk = $this->primary;
    $this->headTitle($table);
    $this->headLink()->appendStylesheet($this->asset('css/crud.css'));
    $this->headLink()->appendStylesheet($this->asset('css/crud_ie.css'), null, 'IE');
?>

<?php if (!empty($this->useOwnLayout) || !$this->hasLayout()) echo $this->render('_partials/head.phtml'); ?>

<div id="crud">

<div class="box">
<div class="tabs">
<?php echo $this->nav(array(
    'Tables' => $this->urlTo('crud'),
    'List' => $this->urlTo('crud')->action('list')->table($this->table),
    'New ' . $singular => $this->urlTo('crud')->action('create')->table($this->table),
), 1); ?>
</div>
<div class="panel">
    <div class="corners-top"><div class="left"></div><div class="right"></div></div>
    <div class="content">

<?php if (!empty($this->messages)) : ?>
<div id="crud-messages">
    <p>
    <?php echo implode("</p>\n<p>", $this->messages); ?>
    </p>
</div>
<?php endif; ?>

<h2>Listing contents of table <?php echo $table ?></h2>

        <table class="db-table" cellspacing="0">
            <tr>
                <th colspan="3">Actions</th>
<?php foreach ($this->headers as $header) : ?>
                <th><?php echo $this->sortLink($header) ?></th>
<?php endforeach ?>
            </tr>
<?php if (!count($this->data)) : ?>
            <tr>
                <td colspan="<?php echo count($this->headers)+3 ?>">This table is empty.</td>
            </tr>
<?php else : $rowNo = 0; ?>

<?php    foreach( $this->data as $row ) : ?>
            <tr<?php echo ++$rowNo % 2 == 0 ? ' class="even"' : null ?>>
                <td class="row-action"><a href="<?php echo $this->pkLink($pk, $row, 'read') ?>">Show</a></td>
                <td class="row-action"><a href="<?php echo $this->pkLink($pk, $row, 'update') ?>">Edit</a></td>
                <td class="row-action"><a href="<?php echo $this->pkLink($pk, $row, 'delete') ?>">Delete</a></td>
<?php        foreach( $row as $col=>$value ) : ?>
                <td<?php echo $col == $this->sort ? ' class="sorted"' : null ?>><?php echo $this->truncate($value, 20) ?></td>
<?php        endforeach ?>
            </tr>
<?php    endforeach ?>
<?php endif ?>
        </table>
<?php echo $this->paginationControl($this->data, 'elastic', '_partials/pagination_control.phtml') ?>

    </div>
    <div class="corners-bottom"><div class="left"></div><div class="right"></div></div>
</div>

</div>

</div>

<!-- crud/index/list: $Id: list.phtml 54 2009-12-20 03:00:49Z monzee@gmail.com $ -->

<?php if (!empty($this->useOwnLayout) || !$this->hasLayout()) echo $this->render('_partials/foot.phtml'); ?>